

#include "log.h"
#include "data_xml.h"
#include "util.h"

#include "transfer_complete_xml.h"

int evcpe_fault_struct_to_xml(struct evcpe_fault_struct *fault_struct,
		const char *node, struct evbuffer *buffer)
{
	int rc;

	if ((rc = evcpe_add_buffer(buffer, "<%s>\n", node)))
		goto finally;

	if ((rc = evcpe_xml_add_int(buffer, "FaultCode", fault_struct->FaultCode)))
		goto finally;

	if ((rc = evcpe_xml_add_string(buffer, "FaultString", fault_struct->FaultString)))
		goto finally;

	if ((rc = evcpe_add_buffer(buffer, "</%s>\n", node)))
		goto finally;

finally:
	return rc;
}


int evcpe_transfer_complete_to_xml(struct evcpe_transfer_complete *method, struct evbuffer *buffer)
{
	int rc;

	evcpe_debug(__func__, "marshaling transfer_complete");

	if ((rc = evcpe_xml_add_string(buffer,
			"CommandKey", method->CommandKey)))
		goto finally;

	if ((rc = evcpe_fault_struct_to_xml(&method->FaultStruct, "FaultStruct", buffer)))
		goto finally;

	if ((rc = evcpe_xml_add_string(buffer,
			"StartTime", method->StartTime)))
		goto finally;

	if ((rc = evcpe_xml_add_string(buffer,
			"CompleteTime", method->CompleteTime)))
		goto finally;

finally:
	return rc;
}

